<?php defined('BASEPATH') OR exit('No direct script access allowed');

class  Admin_Config extends Admin_Controller{
	
	protected $section = 'config';
	var $namespace = "news";
	
	function __construct(){
		parent::__construct();	
		$this->lang->load($this->namespace,$this->lang_current);
		$this->load->model('settings/settings_m');
		
	}	
	function index(){		
		$this->action = 'save|javascript:void(0)|'.lang('global:save')  
						.'+ back|javascript:void(0)|'.lang('global:back');		
		$post = $this->input->post();
		$this->form_validation->set_rules('max_height', lang('product:max_height'), 'required|max_length[4]|numeric');
		$this->form_validation->set_rules('max_width', lang('product:max_width'), 'required|max_length[4]|numeric');
		$this->form_validation->set_rules('thumbs_height', lang('product:thumbs_height'), 'required|max_length[3]|numeric');
		$this->form_validation->set_rules('thumbs_width', lang('product:thumbs_width'), 'required|max_length[3]|numeric');
		
		$type =  substr($this->input->post('btnAction'), 0);
		if($type == 'edit'){
			if ($this->form_validation->run() == TRUE)
			{
				unset($post['btnAction']);
//				print_r($post);exit;
				$this->settings_m->update_list($this->module,$post);
			}
		}
		$model = $this->settings_m->get_all($this->module);
		$this->template
			->title(lang('news:config'))
			->set('model',$model)
			->append_css('error.css')
			->set('action',$this->action)
			->set('help',lang('news:config:help'))
			->set_breadcrumb(lang('news:news'), 'admin/news')
			->set_breadcrumb(lang('news:config'))
			->build($this->controller.'/'.$this->method);
	}
}